import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';

class YBWenZhangWeChatPage extends StatefulWidget {
  @override
  _YBWenZhangWeChatPageState createState() => _YBWenZhangWeChatPageState();
}

class _YBWenZhangWeChatPageState extends State<YBWenZhangWeChatPage> {

  TextEditingController _editingController = TextEditingController();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getData().then((value){
      _editingController.text = value.text;
    });
  }

  static Future<ClipboardData> getData() async {
    ClipboardData r = await Clipboard.getData('text/plain');
    return r;
  }


  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(
          title: Text(YBChineseText.workTaiZhuanFaWenZhangTitle,style: YBTextStyle.TextStyle30313320Medium,),
          elevation: 0,
          actions: [
            Container(
              child: InkWell(
                child: Padding(
                  padding: EdgeInsets.only(right: 20),
                  child: Center(
                    child: Text(YBChineseText.workTaiNextStepTitle,style: YBTextStyle.TextStyle1C1D1F15,),
                  ),
                ),
                onTap: () async {
                  if (_editingController.text.startsWith('https://mp.weixin.qq.com')){
                     YBApplication.router.navigateTo(context, '/workTaiPage/workTaizhuanzaiWechatWenZhangPage/workTaizhuanzaiWechatDisplayPage?wechatUrl=${Uri.encodeComponent(_editingController.text)}');
                  }else{
                     EasyLoading.showError(YBChineseText.sorryWeChatInfoTitle);
                  }
                },
              ),
            ),
          ],
        ),
        body: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              Container(
                height: YBTextStyle.adapterSize8,
              ),
              Container(
                color: YBColor.white,
                child: Padding(
                  padding:EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                  child: TextField(
                    decoration: InputDecoration(
                      border: InputBorder.none,
                      hintText:YBChineseText.workTaiTextFieldTitle,
                    ),
                    controller: _editingController,
                  ),
                ),
              ),
              Container(
                child: Padding(
                  padding:EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20),
                  child: Text(YBChineseText.workTaiGetGongZhongHaoLianTitle,style: YBTextStyle.TextStyle18181814Medium,),
                ),
              ),
              Container(
                child: Padding(
                  padding:EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize10),
                  child: Text(YBChineseText.workTaiZhuangZaiGongZhongHaoWenZhangTitle,style: YBTextStyle.TextStyle7A7A7A12,),
                ),
              ),
              Container(
                child: Padding(
                  padding:EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize10),
                  child: Image.asset(YBImageStyle.getImagePath('shengyuanxiediyibu_fenxianghu')),
                ),
              ),
              Container(
                child:Padding(
                  padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize10),
                  child:Text(YBChineseText.workTaiPopViewMenuCopyTitle,style: YBTextStyle.TextStyle7A7A7A12),
                ),
              ),
              Container(
                child:Padding(
                  padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize10),
                  child:Image.asset(YBImageStyle.getImagePath('shengyuanxiedierbu_fenxianghu')),
                ),
              ),
              Container(
                child:Padding(
                  padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize10),
                  child:Text(YBChineseText.workTaiStepThreeCopythatTitle,style: YBTextStyle.TextStyle7A7A7A12),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
